//
//  CMessageMgr.h
//  wanzhaoIM
//
//  Created by liuyuantao on 15/5/20.
//  Copyright (c) 2015年 liuyuantao. All rights reserved.
//

#import <Foundation/Foundation.h>
@class CMessageModel;
@interface CMessageMgr : NSObject


//查询所有未读消息id
- (NSArray *)loadAllUnReadMessgeID;
//将所有消息更新为已读
- (BOOL)updateAllMessageReadSatuWithIdArray:(NSArray *)idArray;
//更新群文件消息的查看状态
- (BOOL)updateGroupFileLookStatusWithGroupId:(NSString *)groupId array:(NSArray *)array;
//获取未查看群文件的消息
- (NSArray *)loadNoLookFileMessageWithGroupId:(NSString *)groupId;
//搜索消息
- (NSArray *)searchMessageWithSearchStr:(NSString *)searchStr groupId:(NSString *)groupId;
- (NSArray *)searchMessageWithSearchStr:(NSString *)searchStr mineId:(NSString *)mineId friendId:(NSString *)friendId;
- (NSArray*)searchMessageWithSearchStr:(NSString *)searchStr;
//个人聊天记录
//获取个人聊天信息数
- (NSInteger)loadAllcountWithFriendId:(NSString *)friendId mineId:(NSString *)mineId;
- (NSArray *)loadreduceMoreGroupHistoryMessageWithFriendId:(NSString *)frienId mineId:(NSString *)mineId Page:(NSString *)page PerPage:(NSString *)PerPage TimeStamp:(NSString *)TimeStamp;
- (NSArray *)loadMoreHistoryMessageWithFriendId:(NSString *)friendId mineId:(NSString *)mineId Page:(NSString *)page PerPage:(NSString *)PerPage TimeStamp:(NSString *)TimeStamp;

//插入消息
-(BOOL)insertMessage:(CMessageModel *)message;
//批量插入数据
-(BOOL)batchInsertMessages:(NSArray *)messagList;
//删除所有的 消息
-(BOOL)delAllMessages;

//删除单条 消息
-(BOOL)delMessageWithMessageId:(NSString *)messageId;
-(BOOL)delMessages:(CMessageModel *)message;
//更新消息
-(BOOL)updateMessage:(CMessageModel *)message;
//加在消息
//-(NSArray *)loadMessages:(NSString *)fromUser GroupId:(NSString *)groupId beginIndex:(NSInteger)beginIndex messageCount:(NSInteger)messageCount;

-(BOOL)updateMessageReadStatus:(CMessageModel *)message readStatus:(BOOL)readStatus;
//更新消息的已读/未读状态
-(BOOL)updateMessageReadStatusWithMessageId:(NSString *)messageId;
//更新语音消息的已听未听状态
- (BOOL)updateMessageSoundStatusWithMessageId:(NSString *)messageId;
//更新消息的已读 未读状态
-(BOOL)updateMessageReadStatusByFrom:(NSString *)fromUser GroupId:(NSString *)groupId  readStatus:(BOOL)readStatus;

-(NSArray *)loadmessageList;
//删除跟某人的消息记录
- (void)delMessageWithMineUserId:(NSString *)MineUserId FriendUserId:(NSString *)FriendUserId;
//获取所有的未读数
- (NSInteger)loadAllUnReadCount;
- (NSInteger)loadUnReadCountWithMineUserId:(NSString *)MineUserId FriendUserId:(NSString *)FriendUserId;

- (NSArray *)loadAllUnReadMessageWithMineUserId:(NSString *)MineUserId FriendUserId:(NSString *)FriendUserId;
 
//群的所有消息条数
- (NSInteger)loadAllcount:(NSString *)GroupId;
- (void)updateMessageReadStatusWithMineUserId:(NSString *)MineUserId FriendUserId:(NSString *)FriendUserId Status:(BOOL)ReadStatus;
-(NSArray *)loadMessageWithMineId:(NSString *)MineId FrinendId:(NSString *)FriendId TimeStamp:(NSString *)TimeStamp;
-(NSArray *)loadMessageWithMineId:(NSString *)MineId FrinendId:(NSString *)FriendId Page:(NSString *)page PerPage:(NSString *)PerPage;
- (NSArray *)loadMoreHistoryMessageWithMineId:(NSString *)MineId FrinendId:(NSString *)FriendId Page:(NSString *)page PerPage:(NSString *)PerPage TimeStamp:(NSString *)TimeStamp;

//群消息处理
-(NSArray *)loadGroupMessageWithGroupId:(NSString *)GroupId Page:(NSString *)page PerPage:(NSString *)PerPage;
- (NSInteger)loadGroupUnReadCountWithGroupdId:(NSString *)GroupId;

//获取所有未读消息
- (NSArray *)loadAllUnReadMessageWithGroupdId:(NSString *)GroupId;

-(NSArray *)loadGroupMessageWithGroupId:(NSString *)GroupId TimeStamp:(NSString *)TimeStamp;

//  获取我发送的消息的最大消息id
- (CMessageModel *)loadGroupMineSendMaxMessageIndexWithGroupId:(NSString *)groupId;
- (CMessageModel *)loadMineSendMaxMessageIndexWithMineUserId:(NSString *)MineUserId FriendUserId:(NSString *)FriendUserId;

//加载所有正在发送的消息
- (NSArray *)loadGroupAllIsSendingMessageWithGroupId:(NSString *)groupId;
- (NSArray *)loadAllIsSendingMessageWithMineUserId:(NSString *)MineUserId FriendUserId:(NSString *)FriendUserId;

- (NSArray *)loadMoreGroupHistoryMessageWithGroupId:(NSString *)GroupId Page:(NSString *)page PerPage:(NSString *)PerPage TimeStamp:(NSString *)TimeStamp;
//群消息
- (NSArray *)loadreduceMoreGroupHistoryMessageWithGroupId:(NSString *)GroupId Page:(NSString *)page PerPage:(NSString *)PerPage TimeStamp:(NSString *)TimeStamp;
- (void)updateGroupMessageReadStatusWithGroupId:(NSString *)GroupId Status:(BOOL)ReadStatus;
- (void)delGroupMessageWithGroupId:(NSString *)GroupId;


//查询id最小的未读消息
- (CMessageModel *)loadGroupMinUnReadMessageWithGroupId:(NSString *)groupId;
- (CMessageModel *)loadMinUnReadMessageWithMineUserId:(NSString *)MineUserId FriendUserId:(NSString *)FriendUserId;
//删除外部联系人但是不删除聊天记录，就是将message的IsShowInmessageList ＝ 0
- (BOOL)updateMessageWithIsShowInMessageList:(BOOL)IsShowInMessageList;
- (BOOL)updateMessageWithIsShowInMessageList:(BOOL)IsShowInMessageList groupId:(NSString *)GroupId;
- (BOOL)updateMessageWithIsShowInMessageList:(BOOL)IsShowInMessageList FriendId:(NSString *)FriendId MineId:(NSString *)MineId;




- (NSArray *)loadGroupUnReadMessageWithGroupdId:(NSString *)GroupId beginTimeStamp:(NSString *)beginTimeStamp endTimeStamp:(NSString *)endTimeStamp;
- (NSArray *)loadUnReadMessageWithMineUserId:(NSString *)MineUserId FriendUserId:(NSString *)FriendUserId beginTimeStamp:(NSString *)beginTimeStamp endTimeStamp:(NSString *)endTimeStamp;

//获取所有群id
- (NSArray *)loadAllMessageGroupId;

- (NSArray *)updateMessageStatuIsSendingToFailed;
- (BOOL)batchUpdateStatuWithIndeList:(NSArray *)indexList;

- (BOOL)updateMessageStatuIsSendingToFailedWithArray:(NSArray *)array;
//根据 messageIndex请求消息
-(CMessageModel *)loadMessageByMessageId:(NSString *)messageId;
//根据messageId加载message
- (CMessageModel *)loadMessageWithMessageId:(NSString *)messageId;
- (NSArray *)LoadMessageStatuIsSending;
@end
